document.querySelector('.bg-ipt').addEventListener('change',e=>{
    const fd=new FormData()
    fd.append('img',e.target.files[0])
    axios({
        url:'http://hmajax.itheima.net/api/uploadimg',
        method:'POST',
        data:fd
    }).then(result=>{
        const imgUrl=result.data.data.url
        document.body.style.backgroundImage=`url(${imgUrl})`
        //在本地保存
        localStorage.setItem('bgImg',imgUrl)
    })
})

const bgUrl=localStorage.getItem('bgImg')
bgUrl && (document.body.style.backgroundImage=`url(${bgUrl})`)